import { getState, setState } from '@/store/modules/vuexStorange'

/** 基本用户信息 */
const state = {
	basicUser: null,
	user: null,
	taskImgList: [],
	staffIDList: []
}

const getters = {
	// 基本用户信息
	getBasicUser: (state) => {
	 getState(state, 'basicUser', 'basicUser')
		return state.basicUser
	},
	// 后台管理用户信息
	getUser: (state) => {
		getState(state, 'user', 'userInfo')
		return state.user
	}
}

const actions = {
	// 基本用户信息
	setBasicUser({
		commit,
		dispatch,
		getters,
		rootGetters,
		rootState,
		state
	}, userInfo) {
		commit('SET_BASIC_USER', userInfo)
	},
	delBasicUser({
		commit,
		dispatch,
		getters,
		rootGetters,
		rootState,
		state
	}) {
		commit('DEL_BASIC_USER')
	},
	// 后台管理用户信息
	setUser({
		commit,
		dispatch,
		getters,
		rootGetters,
		rootState,
		state
	}, userInfo) {
		commit('SET_USER', userInfo)
	},
	delUser({
		commit,
		dispatch,
		getters,
		rootGetters,
		rootState,
		state
	}) {
		commit('DEL_USER')
	},
	setTaskImgList({ commit }, imgList = []) {
		commit('SET_TASK_IMGLIST', imgList)
	},
	setStaffIDList({ commit }, staffList = []) {
		commit('SET_STAFF_IDLIST', staffList)
	}
}

const mutations = {
	// 基本用户信息
	SET_BASIC_USER(state, userInfo = {}) {
		setState(state, userInfo, 'basicUser', 'basicUser')
	},
	DEL_BASIC_USER(state) {
		state.basicUser = ''
	},
	// 后台管理用户信息
	SET_USER(state, userInfo = {}) {
		setState(state, userInfo, 'user', 'userInfo')
	},
	DEL_USER(state) {
		state.user = ''
	},
	SET_TASK_IMGLIST(state, imgList = []) {
		state.taskImgList = imgList
	},
	SET_STAFF_IDLIST(state, staffList = []) {
		state.staffIDList = staffList
	}
}

export default {
	state,
	getters,
	actions,
	mutations
}
